#ifndef __APP_MQTT_H__
#define __APP_MQTT_H__

#include "log.h"
#include "MQTTClient.h"
#include "string.h"

#define ADDRESS "tcp://192.168.42.41:1883"
#define CLIENTID "b253ba38-daf6-4b37-984f-5d8fdc6a1cfb"
#define TOPIC_GTR "gateway_to_remote"
#define TOPIC_RTG "remote_to_gateway"
#define QOS 1
#define TIMEOUT 10000L

/**
 * @brief 初始化MQTT
 * 
 * @return int 0:成功 -1:失败
 */
int app_mqtt_init(void);
/**
 * @brief 发送MQTT消息
 * 
 * @param json json格式的消息
 * @return int 0:成功 -1:失败
 */
int app_mqtt_send(char *json);
/**
 * @brief 关闭MQTT
 * 
 */
void app_mqtt_close(void);
/**
 * @brief 注册接收消息的回调函数
 * 
 * @param callback 回调函数
 */
void app_mqtt_registerRecvCallback(int (*callback)(char *));

#endif
